package com.welike.shibo.service.impl;

import com.welike.shibo.eneity.JsonResult;
import com.welike.shibo.service.*;
import com.welike.shibo.utils.ResultUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author fangyu
 * @version v1.0.0
 * @since 2019/11/26 11:56 上午
 */
@Service
public class HomeServiceImpl implements HomeService {

    @Resource
    private UserService userService;
    @Resource
    private VideoService videoService;
    @Resource
    private AudioService audioService;
    @Resource
    private CommentsService commentsService;

    @Override
    public JsonResult sumForAll() {
        Integer members = userService.count();
        Integer videos = videoService.count();
        Integer audios = audioService.count();
        Integer comments = commentsService.count();
        Map<String, Integer> result = new HashMap<>(1);
        result.put("members", members);
        result.put("videos", videos);
        result.put("audios", audios);
        result.put("comments", comments);
        return ResultUtils.success("result", result);
    }
}
